<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<% String path = request.getContextPath() ;%>
<%@ taglib uri="/WEB-INF/tld/c.tld" prefix="c" %> 
<%@ taglib uri="/WEB-INF/tld/fmt.tld" prefix="fmt" %>
<%@ taglib uri="/WEB-INF/tld/ui.tld" prefix="ui" %>
<%@ taglib uri="/WEB-INF/tld/fn.tld" prefix="fn" %>
<!DOCTYPE html>
<html lang="zh-CN">
 <head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title></title>
<jsp:include page="../../import.jsp" flush="true" />
 </head>
<body class="iframeBody">
	<div class="Wrapper">
		<div>
			<form id="ligerForm" action="">
				<div class="fieldset1 tabel_col clearFix">
					<div class="caption">
						<span class="title">归档申请</span>
					</div>
					<div class="fieldBox col_50">
						<div class="label">合同号</div>
						<div class="field">
						<a href="javascript:detailPrjBtn( ${mgr.prjId})">
						<font color="blue">	${mgr.contractNo}</font>
						</a>
						</div>
					</div>
					<div class="fieldBox col_50">
						<div class="label">交接单名称</div>
						<div class="field">
						
								${mgr.arcReceiptName}
						</div>
					</div>
					<div class="fieldBox col_50">
						<div class="label">版本号</div>
						<div class="field">${mgr.versioni}
						</div>
					</div>
					<c:if test="${mgr.portfolioNumberProvince !=null}">
					<div class="fieldBox col_50">
						<div class="label">省公司档案袋编号</div>
						<div class="field">${mgr.portfolioNumberProvince}
						</div>
					</div>
					</c:if>
					<c:if test="${mgr.portfolioNumber !=null}">
					<div class="fieldBox col_50">
						<div class="label">总部档案袋编号</div>
						<div class="field">${mgr.portfolioNumber}
						</div>
					</div>
					</c:if>
					
					<!-- 筛选条件 -->
					<jsp:include page="arcMgrSS.jsp" flush="true" />
					<!--vdisabled 是流程节点控制页面显示输入  -->
					<c:set var="vdisabled"  value="disabled"/>
					<c:if test="${flag != '000'}">
						<c:set var="vdisabled"  value=""/>
					</c:if>
					<div class="caption">
						<span class="title">合同资料、承租人资料、担保人资料</span>
						${mgr.cstNm} ${mgr.contractNo}	
					</div>
					
					<div class="fieldBox col_100">
						<div style="width: 100%; ">
							<table style="BORDER-COLLAPSE: collapse;margin-bottom:20px" borderColor=#ECECEC height=40 cellPadding=1 width="100%" align=center border=1> 
							<thead>
								<tr style="background:#E7FEF4">
									<th  style="text-align: center;width:5%;"></th>
									<th  style="text-align: center;width:8%">权证类别</th>
									<th  style="text-align: center;width:15%">权证名称</th>
									<th  style="text-align: center;width:8%">资料类型</th>
									<th  style="text-align: center;width:6%">是否必须</th>
									<th  style="text-align: center;width:6%">扫描件</th>
									
									<th  style="text-align: center;width:6%">操作人</th>
									<th  style="text-align: center;width:6%">操作时间</th>
									<th  style="text-align: center;width:6%">归档地点</th>
									<th  style="text-align: center;width:8%">要求归档份数</th>
									<th  style="text-align: center;width:8%">上次归档中份数</th>
									<th  style="text-align: center;width:8%">本次归档份数</th>
									<th  style="text-align: center;width:8%">实际归档份数</th>
									<th  style="text-align: center;width:18%">扫描件上传</th>
								</tr>
							</thead>
							<tbody>
								<c:forEach items="${cList}" var="item" varStatus="status">
								<!--fdisabled 归档地点是省公司跟总公司合同管理员分别控制页面显示输入  实际归档分数checkCount如果是空则默认本次归档分数-->
										<c:set var="fdisabled"  value="disabled"/>
										<c:set var="checkCount"  value="${item.checkCount }"/>
										<c:if test="${(item.arcReceiptDetailVO.arcPlace =='2' and flag =='001') or (item.arcReceiptDetailVO.arcPlace =='1' and flag =='002')}">
											<c:set var="fdisabled"  value=""/>
											<c:if test="${item.checkCount == null }">
												<c:set var="checkCount"  value="${item.thisCount }"/>
											</c:if>
										</c:if>
									<tr>
									<td  style="text-align: center; height:20px;">${status.index+1}</td>
									<td  style="text-align: center; ">${item.fileFlagNm }</td>
									<td  style="text-align: center; ">${item.fileName }</td>
									<td  style="text-align: center; ">${item.dossierTempNm }</td>
									<td  style="text-align: center; ">${item.ischoiceNm }</td>
									<td  style="text-align: center;">${item.arcReceiptDetailVO.isScanRequireNm }</td>
									<td  style="text-align: center;">${item.upUsrCdNm }</td>
									<td  style="text-align: center;"><fmt:formatDate type="date" value="${item.upUsrTm }"/></td>
									<td style="text-align: center; ">${item.arcReceiptDetailVO.arcPlaceNm }</td>
									<td  style="text-align: center; ">
									<c:choose>
  									<c:when test="${item.dossierTemp !='3' and (  flag =='002')}">
											<input  id="checkCount_d_${item.id}" name="checkCount_d_${item.id}"
											value="${item.dossierCount }" type="text"   class="ui-textbox"  ligerui="width: 60" >
									</c:when>	
									<c:otherwise> 
									  ${item.dossierCount }
									</c:otherwise> 
									</c:choose>
									
									<td  style="text-align: center; ">
									<c:if test="${ item.dossierCountI > 0}">
									<font color="red">${item.dossierCountI }</font>
									</c:if>
									</td>
									<td  style="text-align: center; ">${item.thisCount }</td>
									<td  style="text-align: center;">
										
										<!-- 如果是电子的显示连接 -->
										<c:if test="${item.dossierTemp =='3' and item.filePath != null}">
				               			<a  target="_blank" href="${item.filePath }" >查看</a>
				               			</c:if>
				               			<!-- 如果不是电子的，并且归档中的0，显示实际归档分数 -->
				               			<c:if test="${item.dossierTemp !=3 }">
											<input  id="checkCount_p_${item.id}" name="checkCount_p_${item.id}"
											${vdisabled} 
											 value="${checkCount}" type="text"   class="ui-textbox"  ligerui="width: 60" >
										</c:if>
									</td>
									<td  style="text-align: center; ">
										<!-- 如果是连接附件 -->
										<c:if test="${item.ulFlag=='1'}">
											<c:forEach items="${item.ulFiles}" var="file" >
											<a  target="_blank" href="${file.filePath }" >查看</a>
											</c:forEach>
										</c:if>
										<!-- 如果不是连接附件 -->
										<c:if test="${item.ulFlag!='1'}">
											<!-- 不是电子的，只是显示节点的 -->
											<c:if test="${item.dossierTemp !='3' and (flag=='000' )  }">
											 <div  class="upfiles" id="${item.id}" pkId="${item.eleId}"  style="text-align:left"></div>
											</c:if>
											<!-- 不是电子的，不是显示节点的 -->
											<c:if test="${item.dossierTemp !='3'  and flag!='000'  }">
											<div  class="upfiles" id="${item.id}" fflag="1"  pkId="${item.eleId}"  style="text-align:left"></div>
											<div class="fieldBox col_100"  >
							                    	<span id="cst_rl_add_btn" onclick="upload(${item.id})"  class="sq-button sq-button-round">上传</span>
					               			</div>
					               			</c:if>
				               			</c:if>
									</td>
									</tr>
								</c:forEach>
							</tbody>
						</table>
						</div>
					</div>
					
					<div class="caption">
						<span class="title">权证资料</span>						
					</div>
					<c:forEach items="${pList}" var="mgrvo">
					<div class="fieldBox col_100">
					<table style="BORDER-COLLAPSE: collapse;" borderColor=#ECECEC height=25 cellPadding=1 width="100%" align=center border=1> 
						<tr >
						<td >
						<a href="javascript:detailBtn(${mgrvo.mvo.paySchId},${mgrvo.mvo.prjPrdId},${mgrvo.mvo.prjId})">
						<font color="blue">${mgrvo.mvo.paySchNo}</font></a>&nbsp;&nbsp;&nbsp;
						车架号：${mgrvo.mvo.vin}&nbsp;&nbsp;&nbsp;
						挂靠公司：${mgrvo.mvo.lnkCompNm}&nbsp;&nbsp;&nbsp;
						<font color="red">${mgrvo.checkbz}</font>
						</td>
						<td align=right>
						<a align=right href="javascript:commShowFlow('${mgrvo.mvo.buOrgCd}','${mgrvo.mvo.bizFlag}','${mgrvo.mvo.prInsId}',${mgrvo.mvo.capId})">
						<font  color="blue" >${mgrvo.mvo.prInsNo}</font>
						</a>
							</td></tr></table>
						<div style="width: 100%; ">
							 <table style="BORDER-COLLAPSE: collapse;margin-bottom:20px" borderColor=#ECECEC height=40 cellPadding=1 width="100%" align=center border=1> 
							<thead>
								<tr style="background:#E7FEF4">
									<th  style="text-align: center;width:5%;"></th>
									<th  style="text-align: center;width:8%">权证类别</th>
									<th  style="text-align: center;width:15%">权证名称</th>
									<th  style="text-align: center;width:8%">资料类型</th>
									<th  style="text-align: center;width:6%">是否必须</th>
									<th  style="text-align: center;width:6%">扫描件</th>
									
									<th  style="text-align: center;width:6%">操作人</th>
									<th  style="text-align: center;width:6%">操作时间</th>
									<th  style="text-align: center;width:6%">归档地点</th>
									<th  style="text-align: center;width:8%">要求归档份数</th>
									<th  style="text-align: center;width:8%">上次归档中份数</th>
									<th  style="text-align: center;width:8%">本次归档份数</th>
									<th  style="text-align: center;width:8%">实际归档份数</th>
									<th  style="text-align: center;width:18%">扫描件上传</th>
								</tr>
							</thead>
							<tbody>
								<c:forEach items="${mgrvo.ppList}" var="item" varStatus="status">
								<!--fdisabled 归档地点是省公司跟总公司合同管理员分别控制页面显示输入  实际归档分数checkCount如果是空则默认本次归档分数-->
									<c:set var="fdisabled"  value="disabled"/>
									<c:set var="checkCount"  value="${item.checkCount }"/>
									<c:if test="${(item.arcReceiptDetailVO.arcPlace =='2' and flag =='001') or (item.arcReceiptDetailVO.arcPlace =='1' and flag =='002')}">
										<c:set var="fdisabled"  value=""/>
										<c:if test="${item.checkCount  == null}">
											<c:set var="checkCount"  value="${item.thisCount }"/>
										</c:if>
									</c:if>
								<tr>
									<td  style="text-align: center; height:20px;">${status.index+1}</td>
									<td  style="text-align: center; ">${item.fileFlagNm }</td>
									<td  style="text-align: center; ">${item.fileName }</td>
									<td  style="text-align: center; ">${item.dossierTempNm }</td>
									<td  style="text-align: center; ">${item.ischoiceNm }</td>
									<td  style="text-align: center;">${item.arcReceiptDetailVO.isScanRequireNm }</td>
									<td  style="text-align: center;">${item.upUsrCdNm }</td>
									<td  style="text-align: center;"><fmt:formatDate type="date" value="${item.upUsrTm }"/></td>
									<td style="text-align: center; ">${item.arcReceiptDetailVO.arcPlaceNm }</td>
									<td  style="text-align: center; ">
									
									<c:choose>
  									<c:when test="${item.dossierTemp !='3' and (  flag =='002')}">
											<input  id="checkCount_d_${item.id}" name="checkCount_d_${item.id}"
											value="${item.dossierCount }" type="text"   class="ui-textbox"  ligerui="width: 60" >
									</c:when>	
									<c:otherwise> 
									  ${item.dossierCount }
									</c:otherwise> 
									</c:choose>
									</td>
									<td  style="text-align: center; ">
									<c:if test="${ item.dossierCountI > 0}">
									<font color="red">${item.dossierCountI }</font>
									</c:if>
									</td>
									<td  style="text-align: center; ">${item.thisCount }</td>
									<td  style="text-align: center;">
									<!-- 如果是电子的显示连接 -->
									<!-- 如果是抵押页，,则不允许填写 -->
									<!-- 如果不是电子的，并且归档中的0，显示实际归档分数 -->
									<c:choose>
									
									<c:when test="${item.dossierTemp =='3' }">
										<c:if test="${item.filePath != null}">
			               				<a  target="_blank" href="${item.filePath }" >查看</a>
			               				</c:if>
			               			</c:when>
			               			
			               			<c:when test="${fn:contains(item.fileName,'登记证-抵押我司页') }" >
										${item.checkCount }
									</c:when>
			               			
			               			<c:otherwise> 
					               		<input  id="checkCount_p_${item.id}" name="checkCount_p_${item.id}"
										${vdisabled}  
										 value="${checkCount }" type="text"   class="ui-textbox"  ligerui="width: 60" >
										
									</c:otherwise> 
									</c:choose>
									</td>
									<td  style="text-align: center; " >
									<!-- 如果是连接附件 -->
										<c:if test="${item.ulFlag=='1'}">
											<c:forEach items="${item.ulFiles}" var="file" >
											<a  target="_blank" href="${file.filePath }" >查看</a>
											</c:forEach>
										</c:if>
										<!-- 如果不是连接附件 -->
										<c:if test="${item.ulFlag!='1'}">
											<!-- 不是电子的，只是显示节点的 -->
											<c:if test="${item.dossierTemp !='3' and (flag=='000') }">
											 <div  class="upfiles" id="${item.id}" pkId="${item.eleId}"  style="text-align:left"></div>
											</c:if>
											<!-- 不是电子的，不是显示节点的 ，不是归档中的-->
											<c:if test="${item.dossierTemp !='3'  and flag!='000'   }">
											
											<div  class="upfiles" id="${item.id}" fflag="1"  pkId="${item.eleId}"  style="text-align:left"></div>
											<div class="fieldBox col_100"  >
							                    	<span id="cst_rl_add_btn" onclick="upload(${item.id})"  class="sq-button sq-button-round">上传</span>
					               			</div>
					               			</c:if>
			               				</c:if>
									</td>
								<tr>
								</c:forEach>
							</tbody>
						</table>
						</div>
					</div>
					</c:forEach>
					<c:if test="${flag == '001'}">
					<jsp:include page="arcPostAdd.jsp" flush="true" />
					</c:if>
					<jsp:include page="arcPostList.jsp" flush="true" />
					
					
				</div>
				
				<div class="btnsBox" style="text-align:center">
					<c:set var="fflag"  value="0"/>
					<c:if test="${flag != '000'}">
						<c:set var="fflag"  value="1"/>
						<c:if test="${flag == '002'}"> <!--档案管理员归档 -->
						<span id="saveBtn" class="sq-button sq-button-round"  onclick="check();">登记证验真</span>
						</c:if>
						<span id="saveBtn" class="sq-button sq-button-round"  onclick="save();">保存</span>
						<!-- <span id="closeBtn" class="sq-button sq-button-round" onclick="Remove_navTab();">关闭</span> -->
					</c:if>
				</div>
			</form>
		</div>
	</div>
	<jsp:include page="../../system/sysUlFilesRec/sysUlFileRecList2.jsp" flush="true" >
			        
			            <jsp:param name="fflag" value="${fflag}"/>
			        
			            <jsp:param name="tabNm" value="ARC_MGR_DETAIL"/>
    </jsp:include>
    <script type="text/javascript">
	//显示流程
    function commShowFlow(buOrgCd, _bizFlag,_pInstId,_businessKey){
		var _audStsCd="2";
        if(StringUtils.isEmpty(_pInstId)){
            UIUtils.alertWarning(CommonConstant.C_P_INSTANCEID_NOT_HERE);
            return;
        }
        var _formUrl = "/capPay/flow/toAdditionalInfoPage.do?version=2@@capPayId=";
        if(StringUtils.isNotEmpty(buOrgCd) && buOrgCd==ProjectConstant.CODE_BU_ORG_CD_CAR){//汽车金融工行业务
            if(StringUtils.isNotEmpty(rowdata.bizFlag) && rowdata.bizFlag == '2'){
            	_formUrl = "/capital/capPayInfo/toAddPage.do?accCtrl=1@@ctrlKey=3@@bizFlag="+_bizFlag+"@@id=";
            }else{
            	_formUrl = "/capital/capPayInfo/toAddPage.do?accCtrl=1@@ctrlKey=3@@id=";  //汽车金融
            }
        }else if(StringUtils.isNotEmpty(buOrgCd) && buOrgCd==ProjectConstant.CODE_BU_ORG_CD_ZC){//专车事业部
        	_formUrl="/capital/capPayInfo/toAddPageBySpecialCar.do?entrance=0@@id=";
        }else{
        	
        }
        
        
        var params = "?pInsId="+_pInstId+"&status="+_audStsCd+"&businessKey="+_businessKey+"&formUrl="+_formUrl;
        Add_navTab('tab_cst_invoice_flow_'+_businessKey,'查看流程',"<%=path%>/flow/flow/toFlowShowPageFowBus.do"+params);
    }
    </script>
	<script type="text/javascript">
	 	
		var grid;
		
		$(function() {
			$("#ligerForm").ligerForm({
				validate: true
			});
			
			//initGrid();//初始化交接单明细
	    });
		
		
		//保存
		function save(){
			
			var ligerForm = liger.get("ligerForm");
			if (!ligerForm.valid()) {
				$.ligerDialog.SQalert({content: LogUtils.LOG_CMM_MUST_FIX_ITEM_INFO,SQ_type: "warning"});
				return false; 
			}
			<c:if test="${flag == '001'}">
			if(!checkPost()){
				return ;
			}
			</c:if>
			
			var data = ligerForm.getData();//主表数据
			//data["cjson"] = '${cjson}';
			//data["pjson"] = '${pjson}';
			//明细数据JSON.stringify(grid.getData());
			//alert(JSON.stringify(data));
			//alert(JSON.stringify(grid.getData()));
			//alert(JSON.stringify($("#ligerForm").serialize()));
			//console.log((JSON.stringify(data)));
			
			var wait_dialog = null;
			
			$.ajax({
				type: 'post',
				dataType: 'json',
				data: data,
				url: '<%=path%>/archive/arcApplyMain/modifyFlow.do?flag=${flag}&id=${id}',
				beforeSend: function(){
					wait_dialog=$.ligerDialog.SQalert({content: LogUtils.LOG_CMM_DATA_LOADING ,SQ_type: "waitting" });
				},success:function(msg){
					wait_dialog.close();
					if(msg.success == 1){
						$.ligerDialog.SQalert({content: msg.info,SQ_type: "success"});
							//if(id == "") {
								//Remove_navTab();//新增，关闭当前页面
							//}
						window.location.reload();
					}else{
						$.ligerDialog.SQalert({content: msg.info,SQ_type: "error"});
					}
				},error:function (XMLHttpRequest, textStatus, errorThrown) { 
					wait_dialog.close();
					$.ligerDialog.SQalert({content: "网络错误，请稍后重试",SQ_type: "error"});
				} 
			});
		}
		
		//上传
		function upload(id){
			$.ligerDialog.SQopen({
                width: 820,
                height:550,
                title : '上传文件',
                url:'<%=path%>/archive/arcApplyMain/toUpload.do?flag=1&id='+id,
                // 自定义buttons的时候 不要设置 fixButtons: true
                buttons: [{
                	text: "保存", type: 'ok', cls: 'l-dialog-btn-ok', 
                    onclick: function (item, Dialog) {
                        //在子页面里绑定 frameElement.dialog.onOk = function () {}
                        if (Dialog.onOk) {
                        	Dialog.onOk();
                        	//saveUpload(id);
                        	
                        }
                        
                    }
                }, {
                    text: "取消", type: 'cancel', cls: 'l-dialog-btn-no', 
                    onclick: function (item, Dialog) {
                        //在子页面里绑定 frameElement.dialog.onCancel = function () {}
                        if (Dialog.onCancel) Dialog.onCancel();
                    }
                }
                ]
            });
		}
		//验真
		function check(){
			
			
			var wait_dialog = null;
			
			$.ajax({
				type: 'get',
				dataType: 'json',
				url: '<%=path%>/archive/arcApplyMain/noTransD.do?flag=${flag}&id=${id}',
				beforeSend: function(){
					wait_dialog=$.ligerDialog.SQalert({content: LogUtils.LOG_CMM_DATA_LOADING ,SQ_type: "waitting" });
				},success:function(msg){
					wait_dialog.close();
					if(msg.success == 1){
						$.ligerDialog.SQalert({content: msg.info,SQ_type: "success"});
							//if(id == "") {
								//Remove_navTab();//新增，关闭当前页面
							//}
						window.location.reload();
					}else{
						$.ligerDialog.SQalert({content: msg.info,SQ_type: "error"});
					}
				},error:function (XMLHttpRequest, textStatus, errorThrown) { 
					wait_dialog.close();
					$.ligerDialog.SQalert({content: "网络错误，请稍后重试",SQ_type: "error"});
				} 
			});
		}
	</script>
</body>
</html>